/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vera.hibernate.dao;

import org.hibernate.Query;
import org.hibernate.Session;
import vera.hibernate.entity.SystemUsers;
import vera.hibernate.util.HibernateUtil;

/**
 *
 * @author mai da best!!!!!!!!!!
 */
public class SystemUsersDAO {
    public SystemUsersDAO()
    {
        // do nothing
    }
    
    public SystemUsers getUser(String userCode, String userPassword)
    {
        SystemUsers user = null;
        try
        {
            Session s = HibernateUtil.openSession();
            Query q = s.getNamedQuery("loginUser");
            q.setString("userName", userCode);
            q.setString("password", userPassword);
            user = (SystemUsers) q.uniqueResult();
            s.close();
            return user;
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            return user;
        }
    }
}
